package ais.mantianx.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpSession;

/**
 * @author starrysky
 * @title: LoginController
 * @projectName springMvc_Parent
 * @description: 登陆控制器
 * @date 2021/2/619:24
 */
@Controller
@RequestMapping("/user")
public class LoginController {
    @GetMapping("/login")
    public String goLoginPage(){
        return "login";
    }
    @GetMapping("/jumpSucess")
    public String jumpSuccessPage(){
        return "success";
    }

    @PostMapping("/loginInfo")
    public String loginInfo(HttpSession session,String username){
        session.setAttribute("logined",username);
        return "success";
    }

    @GetMapping("/logout")
    public String logout(HttpSession session){
//        session过期了
        session.invalidate();
//        移除
//        session.removeAttribute("logined");
        return "redirect:/index.jsp";
    }}
